<template>
  <div>
    <div>
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          prop="nubmer"
          label="人数">
        </el-table-column>

        <el-table-column
          prop="longw"
          label="龙">
        </el-table-column>
        <el-table-column
          prop="he"
          label="和">
        </el-table-column>
        <el-table-column
          prop="hu"
          label="虎">
        </el-table-column>
        <el-table-column
          prop="serviceCharge"
          label="手续">
        </el-table-column>
        <el-table-column
          prop="reversion"
          label="回收">
        </el-table-column>
        <el-table-column
          prop="recycle"
          label="回收率">
        </el-table-column>
        <el-table-column
          prop="recycleTimer"
          label="每场回收">
        </el-table-column>

      </el-table>
    </div>
    <el-divider content-position="center">下注情况</el-divider>
    <div style="max-width: 500px">
      <el-form :inline="true" :model="formData" class="demo-form-inline">
        <el-form-item>
          <div>
            <el-radio-group v-model="radio">
              <el-radio-button label="龙"></el-radio-button>
              <el-radio-button label="和"></el-radio-button>
              <el-radio-button label="虎"></el-radio-button>
            </el-radio-group>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-video-play" @click="onSubmit">提交出牌控制</el-button>
        </el-form-item>
      </el-form>
    </div>
    <hr>
    <div style="max-width: 500px">
      <el-input v-model.number="recycle" type="number" placeholder="请输入内容" style="width: 180px"></el-input>
      <el-button type="primary" icon="el-icon-setting" @click="recycleClick">设 置 回 收 率</el-button>
    </div>
    <hr>
    <div style="max-width: 500px;margin-top: 20px">
      <el-button style="margin-left: 180px"  type="primary" icon="el-icon-video-play" @click="stopService">暂停/开启服务</el-button>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    created(){
      axios.get("/lhscene").then(resp => {
        if(resp.data.result){
          this.tableData = [resp.data.msg]
        }
      })
    },
    data() {
      return {
        recycle:'',
        tableData: [],
        radio: '和',
        formData: {
          type: ''
        },

      }
    },
    methods: {
      recycleClick(){
        if(this.recycle === ""){
          this.$notify.error({
            title: '错误',
            message: '请输入调整率'
          });
          return
        }
        axios.get("lhsetrecovery",{
          params: {
            recycle : this.recycle
          }
        }).then(resp => {
          this.$notify({
            title: '成功',
            message: resp.data.msg,
            type: 'success'
          });
        }).catch(err => {
          this.$notify({
            title: '警告',
            message: err.data.error,
            type: 'warning'
          });
        })
      },
      stopService(){
        axios.get("lhstopservice").then(resp => {
          if(resp.data.result){
            alert(resp.data.msg)
          }else {
            alert(resp.data.error)
          }
        })
      },
      onSubmit() {
        this.formData.type = -1
        if(this.radio === '龙'){
          this.formData.type = 0
        }else if(this.radio === '和'){
          this.formData.type = 2
        }if(this.radio === '虎'){
          this.formData.type = 1
        }
        if(this.formData.type !== -1){
          axios.get("/lhcontroller",{
            params:{
              type:this.formData.type
            }
          }).then(resp => {
            if(resp.data.result){
              alert(resp.data.msg)
            }else {
              alert(resp.data.error)
            }
          })
        }
        console.log( this.formData.type)
      }
    }
  }
</script>

<style scoped>

</style>
